/**
 * 
 */
package com.crape.common.utils;

import java.util.HashSet;
import java.util.Iterator;
import java.util.Set;

/**
 * @author taoming 2012-9-6 下午03:15:36
 */
public class ArrayUtils {

    public static String[] duplicatRemoval(String[] stringArray) {

        if (stringArray == null || stringArray.length == 0) return null;
        Set set = new HashSet();
        for (int i = 0; i < stringArray.length; i++) {
            set.add(stringArray[i]);
        }
        int size = set.size();
        String[] temp = new String[size];
        Iterator it = set.iterator();
        int i = 0;
        while (it.hasNext()) {
            temp[i] = (String) it.next();
            i++;
        }
        return temp;
    }

    public static void main(String[] args) {
        String[] temp = { "chenkai", "chenkai", "taoming", "taoming" };
        ArrayUtils.duplicatRemoval(temp);
    }

}
